package homework;

import java.util.ArrayList;

public class Java07_NotRemakeEraseTheSameArrayList {
	public static void main(String[] args) {
		/*
		6.ArrayList去重 
		 */
		int[] arr1 = {1,3}, arr2 = {3,4,5,2,6};
		System.out.println(eraseTheSameArrayList(arr1,arr2));
	}
	
	private static ArrayList<Integer> eraseTheSameArrayList(int[] arr1, int[] arr2) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		ArrayList<Integer> delete = new ArrayList<Integer>();
		for(int i:arr1) {
			if(list.contains(i)) {
				if(delete.contains(i)) {
					
				}else {
					delete.add(i);
				}
			}else {
				list.add(i);
			}
		}
		for(int i:arr2) {
			if(list.contains(i)) {
				if(delete.contains(i)) {
					
				}else {
					delete.add(i);
				}
			}else {
				list.add(i);
			}
		}
		for(int i:delete) {
			for(int j=0;j<list.size();j++) {
				if(i==list.get(j)) {
					list.remove(j);
				}
			}
		}
		list.sort((o1,o2)->o1-o2);
		return list;
	}
}
